package tongwentongshu.com.app.activity;

import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import butterknife.BindView;
import tongwentongshu.com.app.R;


/**
 * Created by XiongBin on 2017/7/28.
 */

public class WebViewActivity extends BaseActivity {
    @BindView(R.id.webviwe)
    WebView webviwe;
    String url;

    @Override
    protected int getLayoutResourceId() {
        return R.layout.activity_webview;
    }

    @Override
    protected int getTitleId() {
        return R.string.app_name;
    }

    @Override
    protected void initView() {
        url = getIntent().getExtras().getString("url");
        webviwe.getSettings().setJavaScriptEnabled(true);
        webviwe.getSettings().setDefaultTextEncodingName("UTF-8");
        webviwe.getSettings().setUseWideViewPort(true);
        webviwe.getSettings().setLoadWithOverviewMode(true);
        webviwe.getSettings()
                .setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        webviwe.setWebViewClient(new WebViewClient());
        webviwe.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress) {

            }

            /*
             * (non-Javadoc)
             *
             * @see
             * android.webkit.WebChromeClient#onReceivedTitle(android.webkit
             * .WebView, java.lang.String)
             */
            @Override
            public void onReceivedTitle(WebView view, String titleT) {
                // TODO Auto-generated method stub
                super.onReceivedTitle(view, titleT);
            }
        });
        if (url.contains("http://tongwentongshu.cn/index.php?g=&m=Index&a=get_share_rule&type=1")) {
            title.setText(R.string.share_rn);
        } else if (url.contains("http://tongwentongshu.cn/index.php?g=&m=Index&a=get_share_rule&typeid=3&type=1")) {
            title.setText("充返活动协议");
        }
        webviwe.loadUrl(url);
    }

    @Override
    protected void initData() {

    }
}
